package org.huifei.a8_dynamicproxy1;

import java.lang.reflect.Proxy;

/**
 * @author: huifei
 * @date: 2017-08-30 15:52
 */
public class Test {
    public static void main(String[] args) {

        DynamicSubject dynamicSubject = new DynamicSubject(new Action1());
        Subject subject = null;
        subject = (Subject) Proxy.newProxyInstance(Subject.class.getClassLoader(), new Class[] {Subject.class}, dynamicSubject);
        subject.request();

        System.out.println("------------------------------");

        dynamicSubject.setObject(new Action2());
        subject = (Subject) Proxy.newProxyInstance(Subject.class.getClassLoader(), new Class[] {Subject.class}, dynamicSubject);
        subject.request();


    }
}
